import request from '@/config/axios'

// 开工记录 VO
export interface WorkStartVO {
  id: number // 编号
  serialNo: string // 序列号
  docNo: string // 工单号
  line: string // 产线
  lineId: string // 产线
  equipment: string // 设备
  process: string // 工序
  processCode: string // 工序
  qty: number // 数量
  reworkId: number // 返工ID
  creator:number
}

// 开工记录 API
export const WorkStartApi = {
  // 查询开工记录分页
  getWorkStartPage: async (params: any) => {
    return await request.get({ url: `/opticore/work-start/page`, params })
  },

  // 查询开工记录详情
  getWorkStart: async (id: number) => {
    return await request.get({ url: `/opticore/work-start/get?id=` + id })
  },

  // 新增开工记录
  createWorkStart: async (data: WorkStartVO) => {
    return await request.post({ url: `/opticore/work-start/create`, data })
  },

  // 修改开工记录
  updateWorkStart: async (data: WorkStartVO) => {
    return await request.put({ url: `/opticore/work-start/update`, data })
  },

  // 删除开工记录
  deleteWorkStart: async (id: number) => {
    return await request.delete({ url: `/opticore/work-start/delete?id=` + id })
  },

  // 导出开工记录 Excel
  exportWorkStart: async (params) => {
    return await request.download({ url: `/opticore/work-start/export-excel`, params })
  },

  // 根据序列号查询开工信息
  selectInfoBySerialNo: async (serialNo: string, parentId: number) => {
    return await request.get({ url: `/opticore/work-start/get-work-serial/${serialNo}/${parentId}`})
  },

  // 开工物料关联表存入记录   开工ID  中间库物料Id  创建者  创建时间
  createWorkStartMaterial: async (params: any) => {
    return await request.post({ url: `/opticore/work-material-rel/create`, data: params })
  },
  //根据父id查询物料层级和数量  selectInfoByParentId
  selectInfoByParentId: async (parentId: number) => {
    return await request.get({ url: `/opticore/work-material-rel/selectMaterialByParentId?parentId=` + parentId })
  }
}
